wayland: Properly apply the fake root offset to event coordinates
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 17 Mar 2014 19:11:13 +0000 (15:11 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 17 Mar 2014 19:36:41 +0000 (15:36 -0400)
GdkEvent's x_root and y_root values should be in the same "fake root
window" coordinate space as gdk_window_get_root_coords.

gdk/wayland/gdkdevice-wayland.c

index 88e6e3fe5d5a62c0fc9280741ee8a511be7bf6a6..c4f93aea58ff376e04fcf251a37bbc0afe9cb375 100644 (file)
@@ -242,15 +242,30 @@ get_coordinates (GdkWaylandDeviceData *data,
                  double *x, double *y,
                  double *x_root, double *y_root)
 {
+  int root_x, root_y;
+
   if (x)
     *x = data->surface_x;
   if (y)
     *y = data->surface_y;
-  /* TODO: Do something clever for relative here */
+
+  if (data->pointer_focus)
+    {
+      gdk_window_get_root_coords (data->pointer_focus,
+                                  data->surface_x,
+                                  data->surface_y,
+                                  &root_x, &root_y);
+    }
+  else
+    {
+      root_x = data->surface_x;
+      root_y = data->surface_y;
+    }
+
   if (x_root)
-    *x_root = data->surface_x;
+    *x_root = root_x;
   if (y_root)
-    *y_root = data->surface_y;
+    *y_root = root_y;
 }
 
 static void